import requests
from ascript.android.ui import Dialog
from time import sleep

def download(url):
    try:
        # 发送GET请求
        response = requests.get(url)
        # 检查请求是否成功
        response.raise_for_status()
        # 将响应内容存入变量
        content = response.text
        Dialog.toast("请求成功，正在执行远程代码...",3000,x=0,y=0.28,bg_color="#00FFFFFF")
        print("请求成功，正在执行远程代码...")
        sleep(3)
        return content
    except requests.exceptions.RequestException as e:
        Dialog.toast("网络请求失败",dur=3000)
        print(f"网络请求失败：{str(e)}")
    except Exception as e:
        Dialog.toast("未知错误",dur=3000)
        print(f"未知错误：{str(e)}")
    return None

url = "https://gitee.com/little-try/as_scripts/raw/master/ks_support2/%E5%BF%AB%E6%89%8B%E8%BE%85%E5%8A%A9AS.py"
code = download(url)
if code:
    compiled = compile(code, '<string>', 'exec')
    exec(compiled)
else:
    raise ValueError("执行代码为空")